<?php
namespace app\api\controller;

use app\common\model as M;

/**
 *
 */
class Misc extends \app\api\ApiBase
{
    public $model = '\app\common\model\Misc';

    /**
     * 获取客服二维码
     */ 
    public function kfService()
    {
        $kfQrcode = request()->domain() . '/public/static/images/kfQrcode.jpg';
        $kfPhone  = \think\Env::get('SYSTEM.KF_PHONE');

        // 已登录用户找到其归属的客户经理返回专属二维码
        if ( $this->uid > 0 ) {
            $sales_admin_id = M\User::calcSalesAdminId($this->uid);
            if ( $sales_admin_id > 0 ) {
                $saler = M\TeacherInfo::where('admin_id' , $sales_admin_id)->find();
                if ( $saler ) {
                    if ( $saler->service_qr ) $kfQrcode = $saler->service_qr;
                    if ( $saler->mobile ) $kfPhone = $saler->mobile;
                }
            }
        }
        return $this->returnSuccess(['kfQrcode' => $kfQrcode , 'kfPhone' => $kfPhone]);
    }
    
}//Class End